package com.dili.dd.gpi.enums;


/**
 * HTML 的标准事件类型
 * User: zhaoYuan
 * Date: 14-9-9
 * Time: 下午5:08
 */
public enum EventType implements BaseEnumInterface {

    CLICK(1,"点击事件"),
    HOVER(2,"悬停事件"),
    BLUR(3,"失去焦点事件"),
    CHANGE(4,"change事件"),
    FOCUS(5,"获得焦点事件"),
    /**
     * 当一个元素，或者其内部任何一个元素获得焦点的时候会触发这个事件。
     * 这跟focus事件区别在于，他可以在父元素上检测子元素获取焦点的情况。
     */
    FOCUS_IN(6,"获得焦点事件"),

    /**
     * 当一个元素，或者其内部任何一个元素失去焦点的时候会触发这个事件。
     * 这跟blur事件区别在于，他可以在父元素上检测子元素失去焦点的情况。
     */
    FOCUS_OUT(7,"失去焦点事件"),

    KEY_DOWN(8,"KEY_DOWN"),
    KEY_PRESS(9,"KEY_PRESS"),
    KEY_UP(10,"KEY_UP"),
    MOUSE_DOWN(11,"MOUSE_DOWN"),
    MOUSE_ENTER(12,"MOUSE_ENTER"),
    MOUSE_LEAVE(13,"MOUSE_LEAVE"),
    MOUSE_MOVE(14,"MOUSE_MOVE"),
    MOUSE_OUT(15,"MOUSE_OUT"),
    MOUSE_OVER(16,"MOUSE_OVER"),
    MOUSE_UP(17,"MOUSE_UP"),
    SCROLL(18,"SCROLL"),
    SUBMIT(19,"SUBMIT"),
    DBL_CLICK(20,"双击事件");

    private int val;

    private String desc;

    EventType(int val, String desc) {
        this.val = val;
        this.desc = desc;
    }

    public int getValue() {
        return val;
    }

    public String getDesc() {
        return desc;
    }

    public static EventType getByValue(int val){
        EventType[] values = EventType.values();
        for (EventType value : values) {
            if(value.getValue() == val){
                return value;
            }
        }
        throw new RuntimeException("值为" + val + "的枚举值，在" + EventType.class + "中不存在");
    }

}
